Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Collections.​Generic.​SortedList<​TKey, TValue>

Assembly: System.Collections

Inheritance: object → SortedList

Implemented Interfaces

Represents a collection of key/value pairs that are sorted by key based on the associated <see cref="T:System.Collections.Generic.IComparer`1" /> implementation.

Properties

public int
Capacity
Gets or sets the number of elements that the <see cref="T:System.Collections.Generic.SortedList`2" /> can contain.
public IComparer<​TKey>
Comparer
Gets the <see cref="T:System.Collections.Generic.IComparer`1" /> for the sorted list.
public int
Count
Gets the number of key/value pairs contained in the <see cref="T:System.Collections.Generic.SortedList`2" /> .
public TValue
Item
public IList<​TKey>
Keys
Gets a collection containing the keys in the <see cref="T:System.Collections.Generic.SortedList`2" /> , in sorted order.
public IList<​TValue>
Values
Gets a collection containing the values in the <see cref="T:System.Collections.Generic.SortedList`2" /> .

Methods

public void
Add​(TKey key, TValue value)
Adds an element with the specified key and value into the <see cref="T:System.Collections.Generic.SortedList`2" /> .
key The key of the element to add.
value The value of the element to add. The value can be <see langword="null" /> for reference types.
public void
Clear​()
Removes all elements from the <see cref="T:System.Collections.Generic.SortedList`2" /> .
public bool
ContainsKey​(TKey key)
Determines whether the <see cref="T:System.Collections.Generic.SortedList`2" /> contains a specific key.
Returns <see langword="true" /> if the <see cref="T:System.Collections.Generic.SortedList`2" /> contains an element with the specified key; otherwise, <see langword="false" /> .
key The key to locate in the <see cref="T:System.Collections.Generic.SortedList`2" /> .
public bool
ContainsValue​(TValue value)
Determines whether the <see cref="T:System.Collections.Generic.SortedList`2" /> contains a specific value.
Returns <see langword="true" /> if the <see cref="T:System.Collections.Generic.SortedList`2" /> contains an element with the specified value; otherwise, <see langword="false" /> .
value The value to locate in the <see cref="T:System.Collections.Generic.SortedList`2" /> . The value can be <see langword="null" /> for reference types.
public IEnumerator<​KeyValuePair<​TKey, TValue>>
GetEnumerator​()
Returns an enumerator that iterates through the <see cref="T:System.Collections.Generic.SortedList`2" /> .
Returns An <see cref="T:System.Collections.Generic.IEnumerator`1" /> of type <see cref="T:System.Collections.Generic.KeyValuePair`2" /> for the <see cref="T:System.Collections.Generic.SortedList`2" /> .
public TKey
GetKeyAtIndex​(int index)
Gets the key corresponding to the specified index.
Returns The key corresponding to the specified index.
index The zero-based index of the key within the entire <see cref="T:System.Collections.Generic.SortedList`2" /> .
public TValue
GetValueAtIndex​(int index)
Gets the value corresponding to the specified index.
Returns The value corresponding to the specified index.
index The zero-based index of the value within the entire <see cref="T:System.Collections.Generic.SortedList`2" /> .
public int
IndexOfKey​(TKey key)
Searches for the specified key and returns the zero-based index within the entire <see cref="T:System.Collections.Generic.SortedList`2" /> .
Returns The zero-based index of <paramref name="key" /> within the entire <see cref="T:System.Collections.Generic.SortedList`2" /> , if found; otherwise, -1.
key The key to locate in the <see cref="T:System.Collections.Generic.SortedList`2" /> .
public int
IndexOfValue​(TValue value)
Searches for the specified value and returns the zero-based index of the first occurrence within the entire <see cref="T:System.Collections.Generic.SortedList`2" /> .
Returns The zero-based index of the first occurrence of <paramref name="value" /> within the entire <see cref="T:System.Collections.Generic.SortedList`2" /> , if found; otherwise, -1.
value The value to locate in the <see cref="T:System.Collections.Generic.SortedList`2" /> . The value can be <see langword="null" /> for reference types.
public bool
Remove​(TKey key)
Removes the element with the specified key from the <see cref="T:System.Collections.Generic.SortedList`2" /> .
Returns <see langword="true" /> if the element is successfully removed; otherwise, <see langword="false" /> . This method also returns <see langword="false" /> if <paramref name="key" /> was not found in the original <see cref="T:System.Collections.Generic.SortedList`2" /> .
key The key of the element to remove.
public void
RemoveAt​(int index)
Removes the element at the specified index of the <see cref="T:System.Collections.Generic.SortedList`2" /> .
index The zero-based index of the element to remove.
public void
SetValueAtIndex​(int index, TValue value)
Updates the value corresponding to the specified index.
index The zero-based index of the value within the entire <see cref="T:System.Collections.Generic.SortedList`2" /> .
value The value with which to replace the entry at the specified index.
public void
TrimExcess​()
Sets the capacity to the actual number of elements in the <see cref="T:System.Collections.Generic.SortedList`2" /> , if that number is less than 90 percent of current capacity.
public bool
TryGetValue​(TKey key, TValue& value)
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object